<?php ob_start(); include('header.php');?>
<?php
$dtEqu = new DataTable(constant('DB_TABLE_EQUIPMENT'));
$dtFur = new DataTable(constant('DB_TABLE_FURNITURE'));
$dtRentType = new DataTable(constant('DB_TABLE_RENT_TYPE'));
$equ_list = $dtEqu->get_list('','sn');
$fur_list = $dtFur->get_list('','sn');
$renttype_list = $dtRentType->get_list('','sn');

$DT = new DataTable(constant('DB_TABLE_RENT'));
$info = $DT->get($_REQUEST['id']);
if($info == null)
{
	ob_clean();
	header("Location:index.php");
	exit();
}
?>
<script src="js/jquery-ui-1.7.3.custom/js/jquery-1.3.2.min.js" language="JavaScript" type="text/javascript"></script>
<script language="javascript">
$(function(){
	var equ_id_list = '<?php echo $info['equipment'];?>';
	var fur_id_list = '<?php echo $info['furniture'];?>';
	var renttype_id_list = '<?php echo $info['type'];?>';
	
	equ_id_list = equ_id_list.split(',');
	fur_id_list = fur_id_list.split(',');
	renttype_id_list = renttype_id_list.split(',');
	
	$('.hardware span').each(function(i,v){
		var current_id = $(v).attr('data');
		if($.inArray(current_id,fur_id_list) != -1)
		{
			$(v).addClass('on');
		}else{
			$(v).addClass('off');
		}
	});
	$('.equipment span').each(function(i,v){
		var current_id = $(v).attr('data');
		if($.inArray(current_id,equ_id_list) != -1)
		{
			$(v).addClass('on');
		}else{
			$(v).addClass('off');
		}
	});
	$('.renttype span').each(function(i,v){
		var current_id = $(v).attr('data');
		if($.inArray(current_id,renttype_id_list) != -1)
		{
			$(v).addClass('on');
		}else{
			$(v).addClass('off');
		}
	});
	
	$('.ziliaoleft a:first').trigger('mouseover');
	$('#pro_img').show();
});
function search_act()
{

document.location='zlb.php?sText='+$('input[name=sText]').val();
return false;
}
function change_img(imgUrl)
{
	$('#pro_img').attr('src',imgUrl);
	return false;
}
</script>
<div id="maincontent">
    <div id="search"><table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="193" rowspan="2" align="right"><img src="images/searchpic.jpg" width="169" height="146" /></td>

    <td colspan="2" align="left"><img src="images/searchtitle.jpg" width="102" height="65" /></td>
    </tr>
  <tr>
    <td valign="top"><input type="text" name="sText" id="textfield" /></td>
    <td width="136" align="right" valign="top"><a href="#" onclick="return search_act();"><img src="images/searchbutton.jpg" width="121" height="55" /></a></td>
  </tr>
  
</table>
</div>
    <div id="listmain">

      <div id="listtop1"></div>
      
      <div id="listmain"><div class="xiangxi">
        <div style=" clear:both; height:206px; width:924px;">
          <div class="leftmessage">
            <ul>
            <li><a href="#"><?php echo $info['title'];?></a></li>
            <?php
            $renttype_table = array();
      foreach($renttype_list  as $tmprow)
      {
      	$renttype_table[$tmprow['id']] = $tmprow['name'];
      }
      
      $type_id_list = explode(',',$info['type']);
      	$type_name_str = '';
      	if(is_array($type_id_list))
      	{
      		foreach($type_id_list as $type_id)
      		{
      			if(intval($type_id) > 0)
      			{
      				$type_name_str .= $renttype_table[$type_id].', ';
      			}
      		
      		}
      	}
      	if(strlen($type_name_str) > 0)
      		$type_name_str = substr($type_name_str,0,-2);
            ?>
            <li>類型：<?php echo $type_name_str;?></li>
            <li>坪數：<?php echo $info['size'];?> 坪</li>

            <li>租金：<?php echo $info['cost'];?> 元</li>
            <li>押金：<?php echo $info['pre_cost'];?> 元</li>
            <li>格局：<?php echo $info['style1'];?>房 <?php echo $info['style2'];?>廳 <?php echo $info['style3'];?>衛 <?php echo $info['style4'];?>廚</li>
            </ul>
          </div> 
          <?php
          	$dtRentImage = new DataTable(constant('DB_TABLE_RENT_IMAGE'));
          	$condition = sprintf("`rId`=%d",$_REQUEST['id']);
       	  	$image_list = $dtRentImage->get_list($condition,'sn');
          ?>
          <div class="img">
          <img style="display:none;" width="303" height="203" name="pro_img" id="pro_img"/>
          </div>

          <div class=" ziliaoleft">
            <dl>
            
            <?php 
            foreach($image_list as $rowData)
            {
            ?>
            <dd>
            <a href="#" onclick="return false;" onmouseover="return change_img('<?php echo constant('SITE_URL_PATH').$rowData['image'];?>')"><img src="<?php echo constant('SITE_URL_PATH').$rowData['image'];?>" width="80" height="60" border="0"></a>
            </dd>
            <?php }?>
         
            
            </dl>
            
          </div>
        </div>
      </div>

        <div style="width:920px; margin:0 auto;">
          <div class="otherbg">房屋明細</div>
          
          <div style="padding:10px;">
          <div class="clear" style="margin-bottom:10px;">房屋地址：<?php echo $info['address'];?></div>
          <div class="clear" style="margin-bottom:10px;">樓層：<?php echo $info['height'];?></div>
          <div class="clear" style="margin-bottom:10px;">車位：<?php echo $info['garage'];?></div>
          
         <div class="lable" >家電：</div>
          <div class="equipment">
          <?php foreach($equ_list as $tmpData):?>
          			<span data="<?php echo  $tmpData['id'];?>"><?php echo $tmpData['name'];?></span>
          <?php endforeach;?>
           </div>
			
          <div style="clear:both;">&nbsp;</div>
          <div class="lable">家具：</div>
          <div class="hardware">
          <?php foreach($fur_list as $tmpData):?>
          			<span data="<?php echo  $tmpData['id'];?>"><?php echo $tmpData['name'];?></span>
          <?php endforeach;?>
           </div>
           
          <div class="clear"><div class="lable">特色說明：</div><div style="line-height:26px; padding-left:70px;">
          <?php echo nl2br($info['description']);?>
          </div>
         
          
          </div></div>

        </div>
                        </div>
 <?php include('bottom.php');?>